package com.itlong.cloud.operate;

import com.itlong.cloud.paymenthub.IOperateAssignmentManageServiceClient;
import com.itlong.cloud.thrown.DataAccessException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RestController;

/**
 * <desc>
 *      自动生成首三年云服务费订单
 * </desc>
 *
 * @createDate2020/12/2
 **/
@EnableScheduling
@RestController
public class OperateCloudServiceOrderTime {

    //是否是首次同步（首次同步时同步所有的任务书，之后每天自动同步只同步3年内的任务书），这里是每日同步
    private static final String FIRST_SYNC = "0";

    @Autowired
    private IOperateAssignmentManageServiceClient iOperateAssignmentManageServiceClient;
    /**
     * <desc>
     *      创建云服务费首三年订单
     * </desc>
     *
     * @Author Zhu.yj
     * @createDate  2020/12/2
     */
    @Scheduled(cron = "0 0 4 * * ?")
    public void createCloudServiceCostOrderTimeTask(){
        try {
            iOperateAssignmentManageServiceClient.createCloudServiceCostOrderTimeTask(FIRST_SYNC);
        }catch (Exception e){
            throw new DataAccessException("【云服务费定时任务】定时建云服务首三年订单失败", e);
        }
    }
}
